package com.lxu.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import javax.sql.DataSource;

@Configuration
public class JdbcTemplateConfig {

    @Bean("ds1JdbcTemplate")
    @Primary
    public JdbcTemplate ds1JdbcTemplate(@Qualifier("ds1Source") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    @Bean("ds2JdbcTemplate")
    public JdbcTemplate ds2JdbcTemplate(@Qualifier("ds2Source") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    @Bean("ds3JdbcTemplate")
    public JdbcTemplate ds3JdbcTemplate(@Qualifier("ds3Source") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    @Bean("ds4JdbcTemplate")
    public NamedParameterJdbcTemplate ds4JdbcTemplate(@Qualifier("ds4Source") DataSource dataSource) {
        return new NamedParameterJdbcTemplate(dataSource);
    }
}
